<template>
  <XtxBread v-if="category !== null">
    <XtxBreadItem to="/">首页</XtxBreadItem>
    <XtxBreadItem v-if="category.parentId" :to="`/category/${category.parentId}`">
      {{ category.parentName }}
    </XtxBreadItem>
    <XtxBreadItem v-if="category.id">{{ category.name }}</XtxBreadItem>
  </XtxBread>
</template>
<script>
import { findSubCategoryFilter } from '@/api/category'
export default {
  name: 'SubBread',
  data () {
    return {
      category: {}
    }
  },
  mounted () {
    this.loadData()
  },
  methods: {
    async loadData () {
      const res = await findSubCategoryFilter(this.$route.params.id)
      this.category = res.result
      console.log(res.result)
      console.log(this.category)
      console.log(this.category.id)
    }
  }
}
</script>
